#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->cleanButton, SIGNAL(clicked()), ui->widget, SLOT(clear()));
    connect(ui->redSlider, SIGNAL(valueChanged(int)), ui->widget, SLOT(updateRedColor(int)));
    connect(ui->greenSlider, SIGNAL(valueChanged(int)), ui->widget, SLOT(updateGreenColor(int)));
    connect(ui->blueSlider, SIGNAL(valueChanged(int)), ui->widget, SLOT(updateBlueColor(int)));
    connect(ui->pointsBox, SIGNAL(valueChanged(int)), this, SLOT(setPoints()));
    connect(ui->drawButton, SIGNAL(clicked()), this, SLOT(draw()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::setPoints(){
    int points = ui->pointsBox->value();
    ui->widget->setPoints(points);
}


void MainWindow::draw(){
    setPoints();
    ui->widget->draw();
}
